package com.jiguang.property.controller;


import com.jiguang.property.annotation.Log;
import com.jiguang.property.dto.CostInfoDTO;
import com.jiguang.property.dto.HostelInfoDTO;
import com.jiguang.property.service.CostInfoService;
import com.jiguang.property.service.HostelInfoService;
import com.jiguang.property.tasks.ScheduledTasks;
import com.jiguang.property.utils.Result;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author testjava
 * @since 2025-03-27
 */
@RestController
@RequestMapping("/costInfo")
public class CostInfoController {
    @Autowired
    private CostInfoService costInfoService;
    @Autowired
    private ScheduledTasks scheduledTasks;

    @ApiOperation(value = "获取费用信息列表")
    @PostMapping("list")
    @Log(name = "查询费用信息列表")
    public Result list(@RequestBody CostInfoDTO costInfoDTO) {
        return costInfoService.listCostInfo(costInfoDTO);
    }

    @ApiOperation(value = "查询预收/交费和已收/交费用信息")
    @PostMapping("getCostInfoByMonth")
    public Result getCostInfoByMonth() {
        return costInfoService.getCostInfoByMonth();
    }

    @ApiOperation(value = "查询预收/交费和已收/交费用信息")
    @PostMapping("getCostInfo")
    public Result getCostInfo() {
        return costInfoService.getCostInfo();
    }


    @ApiOperation(value = "通过ID删除费用信息")
    @PostMapping("delete")
    @Log(name = "删除费用")
    public Result delete(String costIds) {
        return costInfoService.deleteHostelInfo(costIds);
    }

    @ApiOperation(value = "编辑费用信息")
    @PostMapping("saveOrUpdate")
    @Log(name = "操作费用信息")
    public Result update(@RequestBody CostInfoDTO costInfoDTO) {
        return costInfoService.updateCostInfo(costInfoDTO);
    }

    @ApiOperation(value = "生成费用信息")
    @PostMapping("generate")
    public Result generate() {
        scheduledTasks.taskAddCost();
        return Result.ok();
    }

    @ApiOperation(value = "催缴费用")
    @PostMapping("urge")
    @Log(name = "催缴费用")
    public Result urge(String userId,String costId) {
        return costInfoService.urge(userId,costId);
    }


}

